$(function(){
	// init select display
	var selector= '<select id="choseInterface"><option value="">--选择需测试的接口--</option>';
	for(var i in INTERFACE_LIST){
		var item= INTERFACE_LIST[i];
		selector+='<option value="'+item.id+'">'+item.name+'</option>';
	}
	selector+='</select>';
	selector= $(selector);
	$('#list').append(selector);
	
	// bind parameters show
	selector.change(function(){
		var id=$('#choseInterface').val();
		if(id=="" || id==null)
			return;
		var item= null;
		for(var i in INTERFACE_LIST){
			var item= INTERFACE_LIST[i];
			if(item.id==id)
				break;
		}
		
		var params_string= '<ul>';
		params_string+= '<li><span class="paramTitle">CmdId</span>: <input readeOnly="true" class="paramIn" value="'+id+'" name="CmdId" />'+'</li>';
		for(var i in item.params){
			params_string+= '<li><span class="paramTitle">'+item.params[i].name+'</span>: <input class="paramIn" value="" name="'
				+item.params[i].key
				+'" /> <span class="tips">'+item.params[i].req+'</span><span class="example">'
				+item.params[i].detail+'</span></li>';
		}
		params_string+='</ul>';
		$('#params').html(params_string);
	});
	
	
	$('#submitButton').click(function(){
		var reqid= $('#choseInterface').val();
		if(reqid=="" || reqid==null)
			return;

		$('#apiForm').attr("action", "/service").submit();

		//window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
	});
});